<!--
 * @Author: Rain
 * @Date: 2021-11-18 10:17:45
 * @LastEditTime: 2024/01/18 13:51:26
 * @Description: Do Something
-->
<template>
  <div class="dashboard-container">
    <div class="dashboard-editor-container">
      <panel-group :data="result" />
      <el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;">
        <line-chart :chart-data="lineChartData" />
      </el-row>
    </div>
  </div>
</template>

<script>
import PanelGroup from './dashboard/PanelGroup'
import LineChart from './dashboard/LineChart'

export default {
  name: 'Dashboard',
  components: {
    PanelGroup,
    LineChart
  },
  data() {
    return {
      lineChartData: {
        expectedData: [],
        actualData: []
      },
      result: {}
    }
  },
  mounted() {
    this.$http.get('/api/wxUser/count').then(_ => {
      this.result = _
      const { lastMonthNewUserList } = _
      lastMonthNewUserList.map(item => {
        this.lineChartData['expectedData'].push(item.day)
        this.lineChartData['actualData'].push(item.userCount)
      })
    })
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .dashboard-editor-container {
    padding: 32px;
    background-color: rgb(240, 242, 245);
    position: relative;

    .github-corner {
      position: absolute;
      top: 0;
      border: 0;
      right: 0;
    }

    .chart-wrapper {
      background: #fff;
      padding: 16px 16px 0;
      margin-bottom: 32px;
    }
  }

  @media (max-width:1024px) {
    .chart-wrapper {
      padding: 8px;
    }
  }
</style>
